home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / TUTORIAL.BIN / Grid.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-01-30  |  52.8 KB  |  2,614 lines

  1. package symantec.itools.db.awt;
  2.  
  3. import java.awt.BorderLayout;
  4. import java.awt.Button;
  5. import java.awt.Canvas;
  6. import java.awt.Color;
  7. import java.awt.Component;
  8. import java.awt.Container;
  9. import java.awt.Dimension;
  10. import java.awt.Event;
  11. import java.awt.FlowLayout;
  12. import java.awt.Font;
  13. import java.awt.FontMetrics;
  14. import java.awt.Frame;
  15. import java.awt.Graphics;
  16. import java.awt.Image;
  17. import java.awt.Panel;
  18. import java.awt.Rectangle;
  19. import java.awt.Scrollbar;
  20. import java.awt.TextField;
  21. import java.util.BitSet;
  22. import java.util.Date;
  23. import java.util.Enumeration;
  24. import java.util.Vector;
  25. import symantec.itools.db.pro.RelationView;
  26. import symjava.sql.SQLException;
  27.  
  28. public class Grid extends Panel {
  29.    boolean autoRedraw;
  30.    Panel toolbar;
  31.    Panel bottomPanel;
  32.    Vector toolbarComponents;
  33.    TvEventHandler eventHandler;
  34.    Matrix cells;
  35.    Matrix colHeadings;
  36.    Matrix cellAttributes;
  37.    Matrix headingAttributes;
  38.    int preferredRowCount;
  39.    int[] splitters;
  40.    boolean fillLastColumn;
  41.    Scrollbar vsb;
  42.    Scrollbar hsb;
  43.    int cursor;
  44.    long clickTime;
  45.    int topRow;
  46.    int leftCol;
  47.    int dragColumn;
  48.    int xDragLast;
  49.    boolean isDragging;
  50.    int headingHeight;
  51.    int cellHeight;
  52.    int clickMargin;
  53.    int currentCursor;
  54.    // $FF: renamed from: im java.awt.Image
  55.    Image field_0;
  56.    // $FF: renamed from: gg java.awt.Graphics
  57.    Graphics field_1;
  58.    int height;
  59.    int width;
  60.    int vsbPosition;
  61.    int hsbPosition;
  62.    long scrollbarTimer;
  63.    DataSource dataSource;
  64.    DataSource headingSource;
  65.    DefaultDataSource rowHeadingSource;
  66.    CellHints hints;
  67.    TableCell currSelectedCell;
  68.    TableCell currCaptureCell;
  69.    TableCell defaultCell;
  70.    boolean tabbed;
  71.    int rowHeadingWidth;
  72.    CellHints rowHeadingHints;
  73.    boolean autoCreate;
  74.    int rowHeadingLabelStyle;
  75.    int firstNumber;
  76.    TableCell headingCell;
  77.    TableCell currHeadingCell;
  78.    TableCell cornerCell;
  79.    public static final int AUTONUMBER = 0;
  80.    public static final int BLANK = 1;
  81.    public static final int USER_DEFINED = 2;
  82.    public static final Integer TABLE_CELL = new Integer(1);
  83.    public static final Integer CORNER_CELL = new Integer(2);
  84.    public static final Integer COLUMN_HEADING = new Integer(3);
  85.    public static final Integer ROW_HEADING = new Integer(4);
  86.    public static String appendRowLabel = "Append";
  87.    public static String deleteRowLabel = "Delete";
  88.    public static String insertRowLabel = "Insert";
  89.    public static String gotoRowLabel = "Goto >>>";
  90.    public static String saveLabel = "Save";
  91.    public static String restartLabel = "Restart";
  92.    public static String undoRowLabel = "Undo";
  93.    public static String undeleteRowLabel = "Undelete";
  94.    public static final int NEW_ROW = 0;
  95.    public static final int CLEAN_ROW = 1;
  96.    public static final int DELETED_ROW = 2;
  97.    public static final int MODIFIED_ROW = 3;
  98.    public static final int GOT_FOCUS = 1004;
  99.    public static final int LOST_FOCUS = 1005;
  100.    public static final int INSERT = 3;
  101.    public static final int DELETE = 4;
  102.    public static final int APPEND = 5;
  103.    public static final int MASTER_CHANGE = 6;
  104.    public static final int UNDELETE = 7;
  105.    public static final int CELL_EVENT = 50;
  106.    public static final int BUTTON_DOWN_EVENT = 50;
  107.    public static final int BUTTON_UP_EVENT = 51;
  108.    public static final int BUTTON_FLICKER_DOWN_EVENT = 52;
  109.    public static final int BUTTON_FLICKER_UP_EVENT = 53;
  110.    public static final int UNDO_CELL_EVENT = 54;
  111.    public static final int GOT_CELL_FOCUS = 55;
  112.    public static final int LOST_CELL_FOCUS = 56;
  113.    public static final int CELL_CONTENT_CHANGE = 57;
  114.    public static final int CELL_KEY_DOWN = 58;
  115.    public static final int CELL_KEY_UP = 59;
  116.    public static final int CELL_MOUSE_UP = 60;
  117.    public static final int CELL_MOUSE_DOWN = 61;
  118.    public static final int CELL_MOUSE_DRAG = 62;
  119.    public static final int CELL_MOUSE_DOUBLE = 63;
  120.    public static final long CLICKTHRESHOLD = 250L;
  121.    public static final int LEFT = 0;
  122.    public static final int CENTER = 1;
  123.    public static final int RIGHT = 2;
  124.    public static final int NO_LINE = 0;
  125.    public static final int THIN_LINE = 1;
  126.    public static final int THICK_LINE = 2;
  127.    public static final int DASHED_LINE = 3;
  128.    public static final int TOP = 0;
  129.    public static final int BOTTOM = 2;
  130.    static TableCell defaultHeadingCell_ = new ButtonCell();
  131.    static boolean defaultsInitialized;
  132.    Panel gotoPanel;
  133.    TextField gotoTextField;
  134.    Button gotoButton;
  135.    int lastScrollValue;
  136.    boolean scrollDown;
  137.    // $FF: renamed from: sb java.awt.Scrollbar
  138.    Scrollbar field_2;
  139.    BitSet selected;
  140.    Coordinate selectionBase;
  141.    Coordinate selectionLimit;
  142.    boolean selectionMade;
  143.  
  144.    static void initDefaults() {
  145.       if (!defaultsInitialized) {
  146.          defaultHeadingCell_.setCoordinates(new Coordinate(0, 0));
  147.          defaultHeadingCell_.type(2);
  148.          defaultsInitialized = true;
  149.       }
  150.  
  151.    }
  152.  
  153.    public Grid() {
  154.       this(3, Color.white);
  155.    }
  156.  
  157.    public Grid(int cols) {
  158.       this(cols, Color.white);
  159.    }
  160.  
  161.    public Grid(long rows) {
  162.       this(rows, 0);
  163.    }
  164.  
  165.    public Grid(long rows, int cols) {
  166.       this(cols, Color.white);
  167.       this.preferredRowCount = (int)rows;
  168.    }
  169.  
  170.    public Grid(int cols, Color bg) {
  171.       this.autoRedraw = true;
  172.       this.toolbarComponents = new Vector();
  173.       this.cells = new Matrix();
  174.       this.colHeadings = new Matrix();
  175.       this.cellAttributes = new Matrix();
  176.       this.headingAttributes = new Matrix();
  177.       this.preferredRowCount = 10;
  178.       this.leftCol = 1;
  179.       this.dragColumn = -1;
  180.       this.xDragLast = -1;
  181.       this.clickMargin = 5;
  182.       this.headingSource = new DefaultDataSource(this);
  183.       this.rowHeadingWidth = 30;
  184.       this.autoCreate = true;
  185.       this.rowHeadingLabelStyle = 1;
  186.       this.firstNumber = 1;
  187.       this.selected = new BitSet();
  188.       this.selectionMade = false;
  189.       this.dataSource = new DefaultDataSource(this);
  190.       this.assignDefaults();
  191.       this.dataSource.setDefaultData();
  192.       this.createColumns(cols);
  193.       ((Component)this).setBackground(bg);
  194.    }
  195.  
  196.    public Grid(RelationView relView) throws SQLException {
  197.       this(relView, relView.getParentRelationView());
  198.    }
  199.  
  200.    Grid(RelationView relView, RelationView masterView) throws SQLException {
  201.       this.autoRedraw = true;
  202.       this.toolbarComponents = new Vector();
  203.       this.cells = new Matrix();
  204.       this.colHeadings = new Matrix();
  205.       this.cellAttributes = new Matrix();
  206.       this.headingAttributes = new Matrix();
  207.       this.preferredRowCount = 10;
  208.       this.leftCol = 1;
  209.       this.dragColumn = -1;
  210.       this.xDragLast = -1;
  211.       this.clickMargin = 5;
  212.       this.headingSource = new DefaultDataSource(this);
  213.       this.rowHeadingWidth = 30;
  214.       this.autoCreate = true;
  215.       this.rowHeadingLabelStyle = 1;
  216.       this.firstNumber = 1;
  217.       this.selected = new BitSet();
  218.       this.selectionMade = false;
  219.       DbaDataStore store = new DbaDataStore(relView, masterView);
  220.       DbDataSource source = new DbDataSource(store, store, store);
  221.       this.dataSource = source;
  222.       this.dataSource.setDefaultData();
  223.       this.assignDefaults();
  224.       this.dataSource.setGrid(this);
  225.       if (this.dataSource.supportsMeta()) {
  226.          try {
  227.             this.dataSource.setupGrid(this);
  228.          } catch (Exception e) {
  229.             ((Throwable)e).printStackTrace();
  230.          }
  231.       }
  232.  
  233.       this.installDefaultEventHandler();
  234.       this.forceRedraw(true);
  235.    }
  236.  
  237.    public Grid(DataSource ds) {
  238.       this.autoRedraw = true;
  239.       this.toolbarComponents = new Vector();
  240.       this.cells = new Matrix();
  241.       this.colHeadings = new Matrix();
  242.       this.cellAttributes = new Matrix();
  243.       this.headingAttributes = new Matrix();
  244.       this.preferredRowCount = 10;
  245.       this.leftCol = 1;
  246.       this.dragColumn = -1;
  247.       this.xDragLast = -1;
  248.       this.clickMargin = 5;
  249.       this.headingSource = new DefaultDataSource(this);
  250.       this.rowHeadingWidth = 30;
  251.       this.autoCreate = true;
  252.       this.rowHeadingLabelStyle = 1;
  253.       this.firstNumber = 1;
  254.       this.selected = new BitSet();
  255.       this.selectionMade = false;
  256.       this.dataSource = ds;
  257.       this.dataSource.setDefaultData();
  258.       this.assignDefaults();
  259.       this.dataSource.setGrid(this);
  260.       if (this.dataSource.supportsMeta()) {
  261.          try {
  262.             this.dataSource.setupGrid(this);
  263.          } catch (Exception e) {
  264.             ((Throwable)e).printStackTrace();
  265.          }
  266.       }
  267.    }
  268.  
  269.    void assignDefaults() {
  270.       initDefaults();
  271.       ((Container)this).setLayout(new BorderLayout());
  272.       ((Component)this).setFont(CellHints.stdFont);
  273.       ((Component)this).setBackground(Color.white);
  274.       ((Component)this).setForeground(Color.black);
  275.       this.vsb = new Scrollbar(1);
  276.       this.vsb.hide();
  277.       this.toolbar = new Panel();
  278.       this.toolbar.setLayout(new FlowLayout(0, 0, 0));
  279.       this.toolbar.setBackground(Color.lightGray);
  280.       this.hsb = new Scrollbar(0);
  281.       Canvas pad = new Canvas();
  282.       ((Component)pad).resize(this.vsb.preferredSize().width, this.hsb.preferredSize().height);
  283.       this.bottomPanel = new Panel();
  284.       this.bottomPanel.setBackground(Color.lightGray);
  285.       this.bottomPanel.setLayout(new BorderLayout());
  286.       this.bottomPanel.add("West", this.toolbar);
  287.       Panel padding = new Panel();
  288.       ((Container)padding).setLayout(new BorderLayout());
  289.       ((Container)padding).add("North", this.hsb);
  290.       this.bottomPanel.add("Center", padding);
  291.       this.bottomPanel.add("East", pad);
  292.       ((Container)this).add("East", this.vsb);
  293.       ((Container)this).add("South", this.bottomPanel);
  294.       this.hints = new CellHints(this);
  295.       this.defaultCell = new BasicCell(this, this.dataSource);
  296.       this.defaultCell.setCoordinates(new Coordinate(0, 0));
  297.       this.defaultCell.setDefaultFlag();
  298.       this.headingHeight = ((Component)this).getFontMetrics(CellHints.stdFont).getHeight() + 4;
  299.       this.cellHeight = this.headingHeight;
  300.       this.rowHeadingSource = new DefaultDataSource(this, true);
  301.       this.rowHeadingHints = new CellHints(this);
  302.       this.setCornerCell(defaultHeadingCell_);
  303.       this.setDefaultRowHeadingCell(defaultHeadingCell_);
  304.  
  305.       try {
  306.          this.rowHeadingSource.setData(0, 1, new ImageStringData(this.dataSource, ""));
  307.          this.rowHeadingSource.setDefaultData(new ImageStringData(this.dataSource));
  308.       } catch (TypeNotSupported var3) {
  309.       }
  310.    }
  311.  
  312.    public void setAutoRedraw(boolean redraw) {
  313.       this.autoRedraw = redraw;
  314.    }
  315.  
  316.    public boolean getAutoRedraw() {
  317.       return this.autoRedraw;
  318.    }
  319.  
  320.    public void installDefaultEventHandler() {
  321.       this.installEventHandler(new DefaultTvEventHandler());
  322.    }
  323.  
  324.    public void installEventHandler(TvEventHandler h) {
  325.       this.eventHandler = h;
  326.       this.eventHandler.setupView(this);
  327.    }
  328.  
  329.    public DataSource getDataSource() {
  330.       return this.dataSource;
  331.    }
  332.  
  333.    public void addAppendButton() {
  334.       this.addToolbarButton(appendRowLabel);
  335.    }
  336.  
  337.    public void addAppendButton(String label) {
  338.       this.removeAppendButton();
  339.       appendRowLabel = label;
  340.       this.addToolbarButton(label);
  341.    }
  342.  
  343.    public void removeAppendButton() {
  344.       this.removeToolbarButton(appendRowLabel);
  345.    }
  346.  
  347.    public void addInsertButton() {
  348.       this.addToolbarButton(insertRowLabel);
  349.    }
  350.  
  351.    public void addInsertButton(String label) {
  352.       this.removeInsertButton();
  353.       insertRowLabel = label;
  354.       this.addToolbarButton(label);
  355.    }
  356.  
  357.    public void removeInsertButton() {
  358.       this.removeToolbarButton(insertRowLabel);
  359.    }
  360.  
  361.    public void addDeleteButton() {
  362.       this.addToolbarButton(deleteRowLabel);
  363.    }
  364.  
  365.    public void addDeleteButton(String label) {
  366.       this.removeDeleteButton();
  367.       deleteRowLabel = label;
  368.       this.addToolbarButton(label);
  369.    }
  370.  
  371.    public void removeDeleteButton() {
  372.       this.removeToolbarButton(deleteRowLabel);
  373.    }
  374.  
  375.    public void addSaveButton() {
  376.       this.addToolbarButton(saveLabel);
  377.    }
  378.  
  379.    public void addSaveButton(String label) {
  380.       this.removeSaveButton();
  381.       saveLabel = label;
  382.       this.addToolbarButton(label);
  383.    }
  384.  
  385.    public void removeSaveButton() {
  386.       this.removeToolbarButton(saveLabel);
  387.    }
  388.  
  389.    public void addRestartButton() {
  390.       this.addToolbarButton(restartLabel);
  391.    }
  392.  
  393.    public void addRestartButton(String label) {
  394.       this.removeRestartButton();
  395.       restartLabel = label;
  396.       this.addToolbarButton(label);
  397.    }
  398.  
  399.    public void removeRestartButton() {
  400.       this.removeToolbarButton(restartLabel);
  401.    }
  402.  
  403.    public void addUndeleteButton() {
  404.       this.addToolbarButton(undeleteRowLabel);
  405.    }
  406.  
  407.    public void addUndeleteButton(String label) {
  408.       this.removeUndeleteButton();
  409.       undeleteRowLabel = label;
  410.       this.addToolbarButton(label);
  411.    }
  412.  
  413.    public void removeUndeleteButton() {
  414.       this.removeToolbarButton(undeleteRowLabel);
  415.    }
  416.  
  417.    public void addUndoButton() {
  418.       this.addToolbarButton(undoRowLabel);
  419.    }
  420.  
  421.    public void addUndoButton(String label) {
  422.       this.removeUndoButton();
  423.       undoRowLabel = label;
  424.       this.addToolbarButton(label);
  425.    }
  426.  
  427.    public void removeUndoButton() {
  428.       this.removeToolbarButton(undoRowLabel);
  429.    }
  430.  
  431.    public void addGotoButton() {
  432.       if (this.gotoPanel == null) {
  433.          this.gotoPanel = new Panel();
  434.          this.gotoPanel.setLayout(new FlowLayout(0, 5, 0));
  435.          this.gotoPanel.add(this.gotoButton = new Button(gotoRowLabel));
  436.          this.gotoPanel.add(this.gotoTextField = new TextField(4));
  437.          this.addToToolbar(this.gotoPanel);
  438.       }
  439.    }
  440.  
  441.    public void removeGotoButton() {
  442.       if (this.gotoPanel != null) {
  443.          this.removeFromToolbar(this.gotoPanel);
  444.          this.gotoPanel = null;
  445.       }
  446.    }
  447.  
  448.    public void addToolbarButton(String label) {
  449.       Enumeration e = this.toolbarComponents.elements();
  450.  
  451.       while(e.hasMoreElements()) {
  452.          Component c = (Component)e.nextElement();
  453.          if (c instanceof Button && ((Button)c).getLabel().equals(label)) {
  454.             return;
  455.          }
  456.       }
  457.  
  458.       this.addToToolbar(new Button(label));
  459.    }
  460.  
  461.    public void removeToolbarButton(String label) {
  462.       Enumeration e = this.toolbarComponents.elements();
  463.  
  464.       while(e.hasMoreElements()) {
  465.          Component c = (Component)e.nextElement();
  466.          if (c instanceof Button && ((Button)c).getLabel().equals(label)) {
  467.             this.toolbarComponents.removeElement(c);
  468.             return;
  469.          }
  470.       }
  471.  
  472.    }
  473.  
  474.    public boolean isToolbarComponent(Object c) {
  475.       return this.toolbarComponents.contains(c) || c == this.gotoTextField || c == this.gotoButton;
  476.    }
  477.  
  478.    public void addToToolbar(Component c) {
  479.       this.toolbarComponents.addElement(c);
  480.       this.toolbar.add(c);
  481.    }
  482.  
  483.    public void removeFromToolbar(Component c) {
  484.       this.toolbarComponents.removeElement(c);
  485.       this.toolbar.remove(c);
  486.    }
  487.  
  488.    public void setFillLastColumn(boolean fill) {
  489.       this.fillLastColumn = fill;
  490.    }
  491.  
  492.    public boolean getFillLastColumn() {
  493.       return this.fillLastColumn;
  494.    }
  495.  
  496.    public synchronized void setHeading(String h, int col, int chars) {
  497.       ButtonCell cell = new ButtonCell(1, col);
  498.       cell.type(1);
  499.       cell.setGrid(this, this.headingSource);
  500.       this.colHeadings.updateElement(0, col - 1, cell);
  501.  
  502.       try {
  503.          this.headingSource.setData(cell.getCoordinates(), new ImageStringData(this.dataSource, h));
  504.       } catch (TypeNotSupported var5) {
  505.       }
  506.  
  507.       this.setHeadingSize(col, chars);
  508.       this.redraw();
  509.    }
  510.  
  511.    public synchronized void setHeadingSize(int col, int chars) {
  512.       CellHints hints = this.getHeadingHints(0, col);
  513.       int width = ((Component)this).getFontMetrics(hints.font).charWidth('W') * chars;
  514.       this.resizeColumn(col, this.splitters[col - 1] + width);
  515.    }
  516.  
  517.    public Dimension preferredSize() {
  518.       int w = 0;
  519.       int h = 0;
  520.       w = this.splitters[this.splitters.length - 1];
  521.       h = (this.preferredRowCount + 1) * this.cellHeight;
  522.       return new Dimension(w, h);
  523.    }
  524.  
  525.    public Dimension minimumSize() {
  526.       return this.preferredSize();
  527.    }
  528.  
  529.    public synchronized void createColumns(int i) {
  530.       this.cellAttributes.removeAllElements();
  531.       this.headingAttributes.removeAllElements();
  532.       this.headingAttributes.addElement(0, 0, new CellHints(this));
  533.  
  534.       for(int col = 1; col <= i; ++col) {
  535.          this.cellAttributes.addElement(0, col, new CellHints(this));
  536.          this.headingAttributes.addElement(0, col, new CellHints(this));
  537.       }
  538.  
  539.       this.splitters = new int[i + 1];
  540.    }
  541.  
  542.    public synchronized void setCornerCell(TableCell c) {
  543.       this.cornerCell = c.cloneCell();
  544.       this.cornerCell.setGrid(this, this.rowHeadingSource);
  545.       this.cornerCell.setCoordinates(new Coordinate(0, 1));
  546.       this.cornerCell.type(3);
  547.    }
  548.  
  549.    public synchronized void setDefaultRowHeadingCell(TableCell c) {
  550.       this.headingCell = c.cloneCell();
  551.       this.headingCell.setGrid(this, this.rowHeadingSource);
  552.    }
  553.  
  554.    public synchronized void setRowHeadingWidth(int w) {
  555.       this.rowHeadingWidth = w;
  556.    }
  557.  
  558.    public synchronized int getRowHeadingWidth(int w) {
  559.       return this.rowHeadingWidth;
  560.    }
  561.  
  562.    public void useRowHeadings(boolean use) {
  563.       this.rowHeadingHints.visible = use;
  564.    }
  565.  
  566.    public boolean isUsingRowHeadings() {
  567.       return this.rowHeadingHints.visible;
  568.    }
  569.  
  570.    public synchronized void setRowLabelHeadingStyle(int s) {
  571.       if (s >= 0 && s <= 2) {
  572.          this.rowHeadingLabelStyle = s;
  573.          if (s == 0) {
  574.             this.rowHeadingSource.doAutoNumbering(true);
  575.          }
  576.  
  577.       } else {
  578.          throw new IllegalArgumentException("Illegal heading label style");
  579.       }
  580.    }
  581.  
  582.    public synchronized void setRowHeadingAlignment(int a) {
  583.       if (a >= 0 && a <= 2) {
  584.          this.rowHeadingHints.align = a;
  585.       } else {
  586.          throw new IllegalArgumentException("Illegal alignment style");
  587.       }
  588.    }
  589.  
  590.    public int getRowHeadingAlignment() {
  591.       return this.rowHeadingHints.align;
  592.    }
  593.  
  594.    public int getRowLabelHeadingStyle() {
  595.       return this.rowHeadingLabelStyle;
  596.    }
  597.  
  598.    public int getFirstAutoNumber() {
  599.       return this.rowHeadingWidth;
  600.    }
  601.  
  602.    public void setupAutonumbering(int first) {
  603.       this.setupAutonumbering(first, this.rowHeadingWidth);
  604.    }
  605.  
  606.    public synchronized void setupAutonumbering(int first, int pixels) {
  607.       this.rowHeadingLabelStyle = 0;
  608.       this.rowHeadingSource.doAutoNumbering(true, first);
  609.       this.rowHeadingHints.visible = true;
  610.       this.rowHeadingWidth = pixels;
  611.    }
  612.  
  613.    public synchronized void setDefaultRowData(String s) {
  614.       this.rowHeadingSource.setDefaultData(new ImageStringData(this.dataSource, s));
  615.    }
  616.  
  617.    public synchronized void setDefaultRowData(Data d) {
  618.       this.rowHeadingSource.setDefaultData(d);
  619.    }
  620.  
  621.    public String getHeading(int col) {
  622.       return this.cells.elementAt(-1, col).toString();
  623.    }
  624.  
  625.    public synchronized void setHeadingFont(Font f, int col) {
  626.       CellHints hints = this.getHeadingHints(0, col);
  627.       hints.font = f;
  628.       this.headingHeight = ((Component)this).getFontMetrics(f).getHeight();
  629.       if (this.autoRedraw) {
  630.          this.redraw(true);
  631.       }
  632.  
  633.    }
  634.  
  635.    public Font getHeadingFont(int col) {
  636.       return this.getHeadingHints(0, col).font();
  637.    }
  638.  
  639.    public TableCell getCurrentCell() {
  640.       return this.currSelectedCell;
  641.    }
  642.  
  643.    public Data getCurrentCellData() throws DataNotAvailable {
  644.       return this.currSelectedCell == null ? null : this.dataSource.getData(this.currSelectedCell.getCoordinates());
  645.    }
  646.  
  647.    public Coordinate getCurrentCellCoordinates() {
  648.       if (this.currSelectedCell == null) {
  649.          return null;
  650.       } else {
  651.          Coordinate c = this.currSelectedCell.getCoordinates();
  652.          return new Coordinate(c.row() + 1, c.col() + 1);
  653.       }
  654.    }
  655.  
  656.    public synchronized void setCurrentCell(int row, int col) {
  657.       --row;
  658.       --col;
  659.       TableCell newSelection = null;
  660.       if (this.currSelectedCell == null || row != this.currSelectedCell.row() || col != this.currSelectedCell.col()) {
  661.          if (!this.cells.contains(row, col)) {
  662.             if (row < 0 || !this.validRow(row) || col < 0 || col >= this.getNumberOfCols()) {
  663.                return;
  664.             }
  665.  
  666.             newSelection = this.getUniqueCell(row, col);
  667.          } else {
  668.             newSelection = (TableCell)this.cells.elementAt(row, col);
  669.          }
  670.  
  671.          this.sendFocusEvents(this.currSelectedCell, newSelection);
  672.       }
  673.  
  674.    }
  675.  
  676.    public synchronized void setColBgColor(int col, Color bg) {
  677.       CellHints h = this.getColHints(col - 1);
  678.       h.bg = bg;
  679.    }
  680.  
  681.    public synchronized void setColFgColor(int col, Color fg) {
  682.       CellHints h = this.getColHints(col - 1);
  683.       h.fg = fg;
  684.    }
  685.  
  686.    public synchronized void setColFont(Font f, int col) {
  687.       CellHints h = this.getColHints(col);
  688.       h.font = f;
  689.       this.cellHeight = ((Component)this).getFontMetrics(f).getHeight() + 4;
  690.       if (this.autoRedraw) {
  691.          this.redraw(true);
  692.       }
  693.  
  694.    }
  695.  
  696.    public Font getColFont(int col) {
  697.       --col;
  698.       return this.getColHints(col).font();
  699.    }
  700.  
  701.    public synchronized void setColEditable(int col, boolean edit) {
  702.       CellHints h = this.getColHints(col - 1);
  703.       h.editable = edit;
  704.    }
  705.  
  706.    public boolean getColEditable(int col) {
  707.       --col;
  708.       return this.getColHints(col).editable();
  709.    }
  710.  
  711.    public synchronized void setHeadingEditable(int col, boolean edit) {
  712.       CellHints h = this.getHeadingHints(0, col);
  713.       h.editable = edit;
  714.    }
  715.  
  716.    public boolean getHeadingEditable(int col) {
  717.       return this.getHeadingHints(0, col).editable();
  718.    }
  719.  
  720.    public synchronized void setHeadingColors(int col, Color fg, Color bg) {
  721.       CellHints h = this.getHeadingHints(0, col);
  722.       h.fg = fg;
  723.       h.bg = bg;
  724.       if (this.autoRedraw) {
  725.          this.redraw(true);
  726.       }
  727.  
  728.    }
  729.  
  730.    public Color getHeadingFg(int col) {
  731.       CellHints h = this.getHeadingHints(0, col);
  732.       return h.fg;
  733.    }
  734.  
  735.    public Color getHeadingBg(int col) {
  736.       CellHints h = this.getHeadingHints(0, col);
  737.       return h.bg;
  738.    }
  739.  
  740.    public int getColumnSize(int i) {
  741.       return this.getColumnWidth(i - 1);
  742.    }
  743.  
  744.    public synchronized void setColumnAlignment(int col, int align) {
  745.       CellHints h = this.getColHints(col - 1);
  746.       h.align = align;
  747.       h = this.getHeadingHints(0, col);
  748.       h.align = align;
  749.    }
  750.  
  751.    public int getNumberOfCols() {
  752.       return this.splitters.length - 1;
  753.    }
  754.  
  755.    public void setTopRow() {
  756.       this.setTopRow(-1);
  757.    }
  758.  
  759.    public synchronized void setTopRow(int row) {
  760.       if (row >= 1) {
  761.          this.topRow = row - 1;
  762.       }
  763.  
  764.       try {
  765.          this.dataSource.validDataRowRange(0, this.topRow + 1);
  766.       } catch (DataNotAvailable var2) {
  767.          if (this.topRow > this.cells.rows() - 1) {
  768.             this.topRow = 0;
  769.          }
  770.       }
  771.    }
  772.  
  773.    public int getNumberOfVisibleRows() {
  774.       this.setTopRow();
  775.       int count = (this.height - 3) / this.cellHeight - 1;
  776.  
  777.       try {
  778.          int dataRows = this.dataSource.validDataRowRange(this.topRow, this.topRow + count);
  779.          int lastCellRow = this.cells.rows();
  780.          count = Math.min(count, Math.max(dataRows, lastCellRow) - this.topRow + 1);
  781.       } catch (DataNotAvailable var4) {
  782.          if (count > this.cells.rows()) {
  783.             count = this.cells.rows() - this.topRow;
  784.          }
  785.       }
  786.  
  787.       return count;
  788.    }
  789.  
  790.    public int getTopRow() {
  791.       return this.topRow;
  792.    }
  793.  
  794.    public void setCapture() {
  795.       if (this.rowHeadingCell(this.currCaptureCell) && this.currSelectedCell != this.currCaptureCell) {
  796.          this.currHeadingCell = null;
  797.       }
  798.  
  799.       this.currCaptureCell = this.currSelectedCell;
  800.    }
  801.  
  802.    public void setCapture(TableCell c) {
  803.       if (this.rowHeadingCell(this.currCaptureCell) && c != this.currCaptureCell) {
  804.          this.currHeadingCell = null;
  805.       }
  806.  
  807.       this.currCaptureCell = c;
  808.    }
  809.  
  810.    public void lostCapture() {
  811.       if (this.rowHeadingCell(this.currCaptureCell)) {
  812.          this.currHeadingCell = null;
  813.       }
  814.  
  815.       this.currCaptureCell = null;
  816.    }
  817.  
  818.    public boolean cellHasCapture() {
  819.       return this.currCaptureCell != null;
  820.    }
  821.  
  822.    public synchronized void clear() {
  823.       this.clearAllSelections();
  824.       this.cells.removeAllElements();
  825.       this.dataSource.clear();
  826.       this.xDragLast = -1;
  827.       this.isDragging = false;
  828.       this.topRow = 0;
  829.       this.leftCol = 1;
  830.       this.vsb.setValue(0);
  831.       this.hsb.setValue(0);
  832.       this.currSelectedCell = this.currCaptureCell = null;
  833.       if (this.autoRedraw) {
  834.          this.redraw(true);
  835.       }
  836.  
  837.    }
  838.  
  839.    public synchronized void addCell(TableCell cell, String s) throws TypeNotSupported {
  840.       cell = cell.cloneCell();
  841.       cell.setGrid(this, this.dataSource);
  842.       this.cells.updateElement(cell.row(), cell.col(), cell);
  843.       this.dataSource.setData(cell.getCoordinates(), new ImageStringData(this.dataSource, s));
  844.       if (this.autoRedraw) {
  845.          this.redraw(true);
  846.       }
  847.  
  848.    }
  849.  
  850.    public synchronized void addTextCell(int r, int c, String s) throws TypeNotSupported {
  851.       --r;
  852.       --c;
  853.       this.dataSource.setData(r, c, new ImageStringData(this.dataSource, s));
  854.       this.redraw();
  855.    }
  856.  
  857.    public synchronized void addImageCell(int r, int c, Image i) throws TypeNotSupported {
  858.       --r;
  859.       --c;
  860.       this.dataSource.setData(r, c, new ImageStringData(this.dataSource, i));
  861.       this.redraw();
  862.    }
  863.  
  864.    public synchronized void addCell(int r, int c, String s, Image i) throws TypeNotSupported {
  865.       --r;
  866.       --c;
  867.       this.dataSource.setData(r, c, new ImageStringData(this.dataSource, s, i));
  868.       this.redraw();
  869.    }
  870.  
  871.    public String getCellText(int r, int c) throws DataNotAvailable {
  872.       --r;
  873.       --c;
  874.       return this.dataSource.getData(r, c).toString();
  875.    }
  876.  
  877.    public Data getCellData(int r, int c) throws DataNotAvailable {
  878.       --r;
  879.       --c;
  880.       return this.dataSource.getData(r, c);
  881.    }
  882.  
  883.    public FontMetrics getCellFontMetrics(TableCell c) {
  884.       Font f = this.getCellFont(c);
  885.       return ((Component)this).getFontMetrics(f);
  886.    }
  887.  
  888.    public void update(Graphics g) {
  889.       this.paint(g);
  890.    }
  891.  
  892.    void checkClipping(Graphics g) {
  893.       Rectangle r = g.getClipRect();
  894.       Dimension d = ((Component)this).size();
  895.       if (r.x != 0 || r.y != 0 || r.width != d.width || r.height != d.height) {
  896.          ((Component)this).repaint();
  897.       }
  898.  
  899.    }
  900.  
  901.    public void paint(Graphics g) {
  902.       this.checkClipping(g);
  903.       if (this.width != ((Component)this).size().width || this.height != ((Component)this).size().height) {
  904.          this.redraw(true);
  905.       }
  906.  
  907.       if (this.field_0 != null) {
  908.          g.drawImage(this.field_0, 0, 0, this);
  909.       }
  910.    }
  911.  
  912.    public void addNotify() {
  913.       super.addNotify();
  914.       ((Component)this).repaint();
  915.    }
  916.  
  917.    public int numRows() {
  918.       return this.cells.rows();
  919.    }
  920.  
  921.    void showScrollbars() {
  922.       Dimension d = ((Component)this).size();
  923.       Dimension actualViewSize = new Dimension();
  924.       Dimension reqdViewSize = new Dimension();
  925.       Dimension hsbSize = this.bottomPanel.preferredSize();
  926.       Dimension vsbSize = this.vsb.preferredSize();
  927.       boolean changed = false;
  928.       boolean showVsb = false;
  929.       int reqdHeight = this.cells.rows();
  930.  
  931.       try {
  932.          this.dataSource.validDataRowRange(0, this.getPageSize().height + 2 + this.topRow);
  933.          reqdHeight = Math.max(reqdHeight, this.dataSource.rows());
  934.       } catch (DataNotAvailable var13) {
  935.       }
  936.  
  937.       actualViewSize.height = this.height - this.headingHeight - 3 - this.bottomPanel.size().height;
  938.       actualViewSize.width = d.width;
  939.       reqdViewSize.height = reqdHeight * this.cellHeight;
  940.       reqdViewSize.width = this.splitters[this.splitters.length - 1] + this.rowHeadingWidth;
  941.       if (reqdViewSize.width > actualViewSize.width) {
  942.          actualViewSize.height -= hsbSize.height;
  943.       } else if (reqdViewSize.width > actualViewSize.width - vsbSize.width && reqdViewSize.height > actualViewSize.height - hsbSize.height) {
  944.          actualViewSize.height -= hsbSize.height;
  945.       }
  946.  
  947.       if (reqdViewSize.height > actualViewSize.height) {
  948.          this.vsb.setValues(this.vsbPosition, 1, 0, reqdHeight - 1);
  949.          this.vsb.setPageIncrement(this.getPageSize().height);
  950.          this.vsb.show();
  951.          showVsb = true;
  952.          changed = true;
  953.          actualViewSize.width -= vsbSize.width;
  954.       } else {
  955.          this.topRow = 0;
  956.          this.vsb.hide();
  957.          showVsb = false;
  958.       }
  959.  
  960.       if (reqdViewSize.width > actualViewSize.width) {
  961.          int i = 1;
  962.          int row = 0;
  963.          int col = 0;
  964.          if (this.currSelectedCell != null) {
  965.             Coordinate c = this.currSelectedCell.getCoordinates();
  966.             row = c.row;
  967.             col = c.col;
  968.          }
  969.  
  970.          for(int shiftLeft = this.splitters[this.leftCol - 1] + this.rowHeadingWidth; i < this.splitters.length && this.splitters[i] - shiftLeft <= actualViewSize.width; ++i) {
  971.          }
  972.  
  973.          this.hsb.setValues(this.hsbPosition, i, 1, this.splitters.length - 1);
  974.          this.hsb.setPageIncrement(1);
  975.          this.hsb.show();
  976.          changed = true;
  977.       } else {
  978.          this.leftCol = 1;
  979.          this.hsb.hide();
  980.       }
  981.  
  982.       if (changed) {
  983.          ((Component)this).getParent().paintAll(((Component)this).getParent().getGraphics());
  984.       }
  985.  
  986.    }
  987.  
  988.    public void show() {
  989.       this.redraw(true);
  990.    }
  991.  
  992.    public int getColumnWidth(int col) {
  993.       if (this.fillLastColumn && col == this.getNumberOfCols() - 1) {
  994.          int var10001 = this.splitters[col];
  995.          return ((Component)this).size().width - var10001 + 1;
  996.       } else {
  997.          return this.splitters[col + 1] - this.splitters[col];
  998.       }
  999.    }
  1000.  
  1001.    boolean rowHeadingCell(TableCell cell) {
  1002.       return cell != null && (cell == this.headingCell || cell == this.currHeadingCell || cell.type() == 2);
  1003.    }
  1004.  
  1005.    public Rectangle getCellBounds(TableCell cell) {
  1006.       return this.getCellBounds((TableCell)cell, (Rectangle)null);
  1007.    }
  1008.  
  1009.    public Rectangle getCellBounds(TableCell cell, Rectangle b) {
  1010.       Coordinate p = cell.getCoordinates();
  1011.       if (cell == this.cornerCell) {
  1012.          return new Rectangle(0, 0, this.rowHeadingWidth + 1, this.headingHeight + 2);
  1013.       } else if (this.rowHeadingCell(cell)) {
  1014.          return this.getRowHeadingBounds(cell, b);
  1015.       } else {
  1016.          return cell.type() == 1 ? this.getHeadingCellBounds(p, b) : this.getCellBounds(p, b);
  1017.       }
  1018.    }
  1019.  
  1020.    private Rectangle getCellBounds(Coordinate c, Rectangle b) {
  1021.       int shiftLeft = this.splitters[this.leftCol - 1];
  1022.       int row = c.row;
  1023.       int col = c.col;
  1024.       int w = this.getColumnWidth(col);
  1025.       int left = this.splitters[col] - shiftLeft - 1 + this.rowHeadingWidth;
  1026.       if (this.leftCol - 1 == col) {
  1027.          ++left;
  1028.       } else {
  1029.          ++w;
  1030.       }
  1031.  
  1032.       if (b == null) {
  1033.          b = new Rectangle();
  1034.       }
  1035.  
  1036.       b.reshape(left, (row - this.topRow) * this.cellHeight + this.headingHeight + 2, w, this.cellHeight + 1);
  1037.       return b;
  1038.    }
  1039.  
  1040.    public Rectangle getHeadingCellBounds(Coordinate coords, Rectangle b) {
  1041.       int shiftLeft = this.splitters[this.leftCol - 1];
  1042.       int col = coords.col;
  1043.       int w = this.getColumnWidth(col);
  1044.       int left = this.splitters[col] - shiftLeft - 1 + this.rowHeadingWidth;
  1045.       if (col == 0) {
  1046.          ++left;
  1047.       } else {
  1048.          ++w;
  1049.       }
  1050.  
  1051.       if (b == null) {
  1052.          b = new Rectangle();
  1053.       }
  1054.  
  1055.       b.reshape(left, 0, w, this.headingHeight + 2);
  1056.       return b;
  1057.    }
  1058.  
  1059.    public Rectangle getRowHeadingBounds(TableCell cell, Rectangle b) {
  1060.       b = this.getCellBounds(cell.getCoordinates(), b);
  1061.       b.x = 0;
  1062.       b.width = this.rowHeadingWidth + 1;
  1063.       return b;
  1064.    }
  1065.  
  1066.    public void redrawCell(TableCell c) {
  1067.       if (c != this.cornerCell && c.type() == 1) {
  1068.          Coordinate coord = c.getCoordinates();
  1069.          this.makeCellVisible(coord.row, coord.col);
  1070.       }
  1071.  
  1072.       this.hints.setHints(c);
  1073.       this.field_1.setColor(((Component)this).getBackground());
  1074.       Rectangle r = this.hints.bounds();
  1075.       this.field_1.fillRect(r.x, r.y, r.width - 1, r.height - 1);
  1076.       this.field_1.setColor(((Component)this).getForeground());
  1077.       c.drawCell(this.field_1, this.hints);
  1078.       if (c == this.currSelectedCell && c.isCellTypeEditable()) {
  1079.          this.frameCurrentCells();
  1080.       }
  1081.  
  1082.       ((Component)this).repaint();
  1083.    }
  1084.  
  1085.    protected void redrawCell(int row, int col) {
  1086.       if (this.validRow(row)) {
  1087.          if (col <= -1 || this.validCol(col)) {
  1088.             if (col == -1 && this.validRow(row)) {
  1089.                this.redrawRowHeadingCell(row);
  1090.             } else if (col != -1 || row != -1) {
  1091.                TableCell c = this.getUniqueCell(row, col);
  1092.                this.redrawCell(c);
  1093.                this.drawTableBoundary();
  1094.             }
  1095.          }
  1096.       }
  1097.    }
  1098.  
  1099.    public void redrawRow(int row) {
  1100.       --row;
  1101.       if (this.validRow(row)) {
  1102.          int cols = this.getNumberOfCols();
  1103.  
  1104.          for(int col = 0; col < cols; ++col) {
  1105.             this.redrawCell(row, col);
  1106.          }
  1107.  
  1108.          this.redrawRowHeadingCell(row);
  1109.       }
  1110.    }
  1111.  
  1112.    public void redrawAroundCell(TableCell c) {
  1113.       int row = c.row() - 1;
  1114.       int col = c.col() - 1;
  1115.  
  1116.       for(int i = 0; i <= 2; ++i) {
  1117.          for(int j = 0; j <= 2; ++j) {
  1118.             if (row + i < this.topRow) {
  1119.                if (col + j < this.leftCol - 1) {
  1120.                   this.redrawCornerCell();
  1121.                }
  1122.  
  1123.                this.redrawColHeadingCell(col + j);
  1124.             } else {
  1125.                this.redrawCell(row + i, col + j);
  1126.             }
  1127.          }
  1128.       }
  1129.  
  1130.    }
  1131.  
  1132.    public Rectangle getTableBounds(Rectangle r) {
  1133.       Dimension d = ((Component)this).size();
  1134.       r.reshape(0, 0, d.width, d.height);
  1135.       if (this.vsb.isVisible()) {
  1136.          r.width -= this.vsb.size().width;
  1137.       }
  1138.  
  1139.       r.height -= this.bottomPanel.size().height;
  1140.       r.width = this.splitters[this.splitters.length - 1] - this.splitters[this.leftCol - 1] + 1;
  1141.       if (this.rowHeadingHints.visible) {
  1142.          r.width += this.rowHeadingWidth;
  1143.       }
  1144.  
  1145.       int visRows = (r.height - 2) / this.cellHeight;
  1146.       if (visRows + this.topRow > this.dataSource.rows()) {
  1147.          r.height = this.headingHeight + 2 + this.cellHeight * (this.dataSource.rows() - this.topRow) + 2;
  1148.       }
  1149.  
  1150.       return r;
  1151.    }
  1152.  
  1153.    protected void drawTableBoundary() {
  1154.       Dimension d = ((Component)this).size();
  1155.       Rectangle r = new Rectangle(0, 0, d.width, d.height);
  1156.       if (this.vsb.isVisible()) {
  1157.          r.width -= this.vsb.size().width;
  1158.       }
  1159.  
  1160.       r.height -= this.bottomPanel.size().height;
  1161.       this.field_1.setColor(Color.black);
  1162.       this.field_1.drawRect(r.x, r.y, r.width - 1, r.height - 1);
  1163.       r.width = this.splitters[this.splitters.length - 1] - this.splitters[this.leftCol - 1] + 1;
  1164.       if (this.rowHeadingHints.visible) {
  1165.          r.width += this.rowHeadingWidth;
  1166.       }
  1167.  
  1168.       int visRows = (r.height - 2) / this.cellHeight;
  1169.       if (visRows + this.topRow > this.dataSource.rows()) {
  1170.          r.height = this.headingHeight + 2 + this.cellHeight * (this.dataSource.rows() - this.topRow) + 2;
  1171.       }
  1172.  
  1173.       this.field_1.drawRect(r.x, r.y, r.width - 1, r.height - 1);
  1174.    }
  1175.  
  1176.    public synchronized void insertRow(int beforeRow) throws TypeNotSupported {
  1177.       Event e = new Event(this, 3, (Object)null);
  1178.       --beforeRow;
  1179.       e.y = beforeRow;
  1180.       if (!this.dataSource.handleEvent(e)) {
  1181.          this.dataSource.insertRow(beforeRow);
  1182.       }
  1183.  
  1184.       if (this.currSelectedCell != null && this.currSelectedCell.row() >= beforeRow) {
  1185.          this.currSelectedCell.setRow(this.currSelectedCell.row() + 1);
  1186.       }
  1187.  
  1188.       if (this.autoRedraw) {
  1189.          this.redraw(true);
  1190.       }
  1191.  
  1192.    }
  1193.  
  1194.    public int rowState(int row) {
  1195.       --row;
  1196.       return this.dataSource.rowState(row);
  1197.    }
  1198.  
  1199.    public void undeleteRow(int row) throws TypeNotSupported {
  1200.       --row;
  1201.       Event e = new Event(this, 7, (Object)null);
  1202.       e.y = row;
  1203.       if (!this.dataSource.handleEvent(e)) {
  1204.          this.dataSource.undeleteRow(row);
  1205.       }
  1206.  
  1207.    }
  1208.  
  1209.    public synchronized void deleteRow(int row) throws TypeNotSupported {
  1210.       --row;
  1211.       Event e = new Event(this, 4, (Object)null);
  1212.       e.y = row;
  1213.       if (!this.dataSource.handleEvent(e)) {
  1214.          this.dataSource.deleteRow(row);
  1215.       }
  1216.  
  1217.       if (this.currSelectedCell != null) {
  1218.          if (this.currSelectedCell.row() == row) {
  1219.             this.currSelectedCell = this.currCaptureCell = null;
  1220.          } else if (this.currSelectedCell.row() > row) {
  1221.             this.currSelectedCell.setRow(this.currSelectedCell.row() - 1);
  1222.          }
  1223.       }
  1224.  
  1225.       if (this.autoRedraw) {
  1226.          this.redraw(true);
  1227.       }
  1228.  
  1229.    }
  1230.  
  1231.    public synchronized int appendRow() throws TypeNotSupported {
  1232.       Event e = new Event(this, 5, (Object)null);
  1233.       int newRow;
  1234.       if (!this.dataSource.handleEvent(e)) {
  1235.          newRow = this.dataSource.appendRow();
  1236.       } else {
  1237.          newRow = e.y;
  1238.       }
  1239.  
  1240.       if (this.autoRedraw) {
  1241.          this.redraw(true);
  1242.       }
  1243.  
  1244.       return newRow;
  1245.    }
  1246.  
  1247.    public void addCellFromDefault(TableCell cell) {
  1248.       TableCell c = cell.cloneCell();
  1249.       this.cells.addElement(c.row(), c.col(), c);
  1250.       if (this.currSelectedCell == cell) {
  1251.          this.currSelectedCell = c;
  1252.       }
  1253.  
  1254.       if (this.currCaptureCell == cell) {
  1255.          this.currCaptureCell = c;
  1256.       }
  1257.  
  1258.    }
  1259.  
  1260.    protected TableCell getDefaultCell(int row, int col) {
  1261.       Coordinate c = this.defaultCell.getCoordinates();
  1262.       this.defaultCell.reset();
  1263.       c.row = row;
  1264.       c.col = col;
  1265.       return this.defaultCell;
  1266.    }
  1267.  
  1268.    protected TableCell getCell(int row, int col) {
  1269.       return this.cells.contains(row, col) ? (TableCell)this.cells.elementAt(row, col) : this.getDefaultCell(row, col);
  1270.    }
  1271.  
  1272.    public void save() throws TypeNotSupported {
  1273.       this.dataSource.commitData();
  1274.       this.dataSource.save();
  1275.    }
  1276.  
  1277.    public void restart() {
  1278.       this.refresh();
  1279.    }
  1280.  
  1281.    public void refresh() {
  1282.       this.dataSource.refresh();
  1283.       this.redraw(true);
  1284.    }
  1285.  
  1286.    public void redraw(boolean repaint) {
  1287.       this.redraw();
  1288.       if (repaint) {
  1289.          ((Component)this).repaint();
  1290.       }
  1291.  
  1292.    }
  1293.  
  1294.    public void redraw() {
  1295.       Dimension d = ((Component)this).size();
  1296.       if (this.width != d.width || this.height != d.height) {
  1297.          this.field_0 = ((Component)this).createImage(this.width = d.width, this.height = d.height);
  1298.          if (this.field_0 == null) {
  1299.             return;
  1300.          }
  1301.  
  1302.          this.field_1 = this.field_0.getGraphics();
  1303.       }
  1304.  
  1305.       this.forceRedraw(false);
  1306.    }
  1307.  
  1308.    public synchronized void forceRedraw(boolean repaint) {
  1309.       if (this.field_1 != null) {
  1310.          this.field_1.setColor(((Component)this).getBackground());
  1311.          this.field_1.fillRect(0, 0, this.width, this.height);
  1312.          this.setTopRow();
  1313.          this.showScrollbars();
  1314.          int count = this.getNumberOfVisibleRows();
  1315.          this.drawHeadings(count);
  1316.          this.drawRows(count, this.topRow);
  1317.          this.drawTableBoundary();
  1318.          if (repaint) {
  1319.             ((Component)this).repaint();
  1320.          }
  1321.  
  1322.       }
  1323.    }
  1324.  
  1325.    void drawRows(int count, int cellRow) {
  1326.       int r = 0;
  1327.       MatrixEnumeration e = this.cells.elements();
  1328.       TableCell c = null;
  1329.       int cols = this.getNumberOfCols();
  1330.       int currRow = -1;
  1331.       int currCol = -1;
  1332.       if (cellRow > 0) {
  1333.          if (cellRow >= this.cells.rows()) {
  1334.             e = null;
  1335.          } else {
  1336.             c = (TableCell)e.advanceTo(cellRow);
  1337.          }
  1338.       }
  1339.  
  1340.       while(count-- > 0) {
  1341.          for(int col = this.leftCol - 1; col < cols; ++col) {
  1342.             this.getColumnWidth(col);
  1343.  
  1344.             while(e != null && (c == null || e.currCol() < col && e.currRow() <= cellRow) && e.hasMoreElements()) {
  1345.                c = (TableCell)e.nextElement();
  1346.                currRow = e.currRow();
  1347.                currCol = e.currCol();
  1348.                if (currRow <= cellRow && currCol < col) {
  1349.                   c = null;
  1350.                }
  1351.             }
  1352.  
  1353.             if (currRow == cellRow && currCol == col) {
  1354.                this.hints.setHints(c);
  1355.                c.drawCell(this.field_1, this.hints);
  1356.                c = null;
  1357.             } else if (this.currSelectedCell != null && this.currSelectedCell.row() == cellRow && this.currSelectedCell.col() == col) {
  1358.                this.hints.setHints(this.currSelectedCell);
  1359.                this.currSelectedCell.drawCell(this.field_1, this.hints);
  1360.             } else {
  1361.                TableCell defCell = this.getDefaultCell(cellRow, col);
  1362.                this.hints.setHints(defCell);
  1363.                defCell.drawCell(this.field_1, this.hints);
  1364.             }
  1365.          }
  1366.  
  1367.          ++cellRow;
  1368.          ++r;
  1369.       }
  1370.  
  1371.       if (this.currSelectedCell != null && this.currSelectedCell.isCellTypeEditable()) {
  1372.          this.frameCurrentCells();
  1373.       }
  1374.  
  1375.    }
  1376.  
  1377.    void frameCurrentCells() {
  1378.       if (this.currSelectedCell != null) {
  1379.          Rectangle r = this.getCellBounds(this.currSelectedCell);
  1380.          if (r.x < this.rowHeadingWidth || r.y < this.headingHeight + 2) {
  1381.             return;
  1382.          }
  1383.  
  1384.          this.field_1.setColor(Color.black);
  1385.          this.field_1.drawRect(r.x - 1, r.y - 1, r.width + 1, r.height + 1);
  1386.          this.field_1.drawRect(r.x + 1, r.y + 1, r.width - 3, r.height - 3);
  1387.       }
  1388.  
  1389.    }
  1390.  
  1391.    int[] getColStartPositions() {
  1392.       return this.splitters;
  1393.    }
  1394.  
  1395.    public void handleException(int row, int col, Exception ex) {
  1396.       if (this.eventHandler != null) {
  1397.          this.eventHandler.handleException(new Coordinate(row, col), ex);
  1398.       }
  1399.  
  1400.    }
  1401.  
  1402.    public void undoRow(int row) throws TypeNotSupported {
  1403.       --row;
  1404.       this.dataSource.undoRow(row);
  1405.    }
  1406.  
  1407.    public void undoCurrentCell() {
  1408.       this.dataSource.rollbackCurrentData();
  1409.       if (this.currSelectedCell != null) {
  1410.          this.redrawCell(this.currSelectedCell.row(), this.currSelectedCell.col());
  1411.       }
  1412.  
  1413.    }
  1414.  
  1415.    public boolean generateEvent(Event e, int id, TableCell cell) {
  1416.       Object oldTarget = e.target;
  1417.       int oldId = e.id;
  1418.       Object oldArg = e.arg;
  1419.       boolean handled = false;
  1420.       e.id = id;
  1421.       e.target = this;
  1422.       e.arg = cell;
  1423.       handled = this.dispatchCellEvent(e);
  1424.       if (!this.dataSource.handleEvent(e)) {
  1425.          handled |= ((Component)this).postEvent(e);
  1426.       }
  1427.  
  1428.       e.target = oldTarget;
  1429.       e.id = oldId;
  1430.       e.arg = oldArg;
  1431.       return handled;
  1432.    }
  1433.  
  1434.    boolean dispatchCellEvent(Event e) {
  1435.       if (this.eventHandler != null && e.arg instanceof TableCell) {
  1436.          TableCell cell = (TableCell)e.arg;
  1437.          if (this.rowHeadingCell(cell)) {
  1438.             return this.eventHandler.handleRowHeadingEvent(e, cell);
  1439.          } else if (cell.type() == 1) {
  1440.             return this.eventHandler.handleColHeadingEvent(e, cell);
  1441.          } else {
  1442.             return cell == this.cornerCell ? this.eventHandler.handleCornerCellEvent(e, cell) : this.eventHandler.handleCellEvent(e, cell);
  1443.          }
  1444.       } else {
  1445.          return false;
  1446.       }
  1447.    }
  1448.  
  1449.    boolean handleHeadingClick(Event e, int x, int y) {
  1450.       int[] colstart = this.getColStartPositions();
  1451.       int shiftLeft = colstart[this.leftCol - 1] - this.rowHeadingWidth;
  1452.       if (x <= this.rowHeadingWidth && this.rowHeadingHints.visible) {
  1453.          if (x < this.rowHeadingWidth + this.clickMargin && x > this.rowHeadingWidth - this.clickMargin) {
  1454.             this.dragColumn = 0;
  1455.             this.isDragging = true;
  1456.             this.mouseDrag(e, x, y);
  1457.             return true;
  1458.          } else {
  1459.             if (this.rowHeadingCell(this.currCaptureCell)) {
  1460.                this.currHeadingCell = null;
  1461.             }
  1462.  
  1463.             this.currCaptureCell = this.cornerCell;
  1464.             this.translate(e);
  1465.             return this.cornerCell.mouseEvent(e);
  1466.          }
  1467.       } else {
  1468.          for(int i = this.leftCol - 1; i < this.splitters.length; ++i) {
  1469.             if (x < colstart[i] + this.clickMargin - shiftLeft && x > colstart[i] - this.clickMargin - shiftLeft) {
  1470.                this.dragColumn = i;
  1471.                this.isDragging = true;
  1472.                this.mouseDrag(e, x, y);
  1473.                return true;
  1474.             }
  1475.          }
  1476.  
  1477.          TableCell cell = (TableCell)this.colHeadings.elementAt(0, this.columnClicked(x));
  1478.          if (cell == null) {
  1479.             return true;
  1480.          } else {
  1481.             if (this.rowHeadingCell(this.currCaptureCell)) {
  1482.                this.currHeadingCell = null;
  1483.             }
  1484.  
  1485.             this.currCaptureCell = cell;
  1486.             this.translate(e);
  1487.             return cell.mouseEvent(e);
  1488.          }
  1489.       }
  1490.    }
  1491.  
  1492.    boolean handleRowHeadingClick(Event e, int x, int y) {
  1493.       this.currHeadingCell = this.headingCell.cloneCell();
  1494.       Coordinate c = this.currHeadingCell.getCoordinates();
  1495.       c.row = this.cellRow(y);
  1496.       c.col = 0;
  1497.       if (!this.validRow(c.row)) {
  1498.          return true;
  1499.       } else {
  1500.          this.currCaptureCell = this.currHeadingCell;
  1501.          this.translate(e);
  1502.          return this.currHeadingCell.mouseEvent(e);
  1503.       }
  1504.    }
  1505.  
  1506.    boolean handleSuccessiveClick(Event e) {
  1507.       long clickSpeed = e.when - this.clickTime;
  1508.       TableCell cell = this.currCaptureCell != null ? this.currCaptureCell : this.currSelectedCell;
  1509.       boolean handled;
  1510.       if (cell == null) {
  1511.          handled = false;
  1512.       } else if (clickSpeed < 250L) {
  1513.          e.target = cell;
  1514.          e.id = 63;
  1515.          this.translate(e);
  1516.          handled = cell.actionEvent(e);
  1517.       } else {
  1518.          e.target = cell;
  1519.          this.translate(e);
  1520.          handled = cell.mouseEvent(e);
  1521.       }
  1522.  
  1523.       this.clickTime = e.when;
  1524.       return handled;
  1525.    }
  1526.  
  1527.    int cellRow(int y) {
  1528.       return (y - this.headingHeight - 2) / this.cellHeight + this.topRow;
  1529.    }
  1530.  
  1531.    int columnClicked(int x) {
  1532.       int shiftLeft = this.splitters[this.leftCol - 1] - this.rowHeadingWidth;
  1533.  
  1534.       for(int i = 0; i < this.getNumberOfCols() - 1; ++i) {
  1535.          if (x < this.splitters[i + 1] - shiftLeft) {
  1536.             return i;
  1537.          }
  1538.       }
  1539.  
  1540.       return x < this.rowHeadingWidth ? -1 : this.getNumberOfCols() - 1;
  1541.    }
  1542.  
  1543.    void sendFocusEvents(TableCell lost, TableCell get) {
  1544.       Event e = new Event(lost, 1005, (Object)null);
  1545.       int oldRow = -1;
  1546.       if (this.currSelectedCell != null) {
  1547.          oldRow = this.currSelectedCell.row();
  1548.       }
  1549.  
  1550.       if (lost != null) {
  1551.          if (!lost.canLoseFocus()) {
  1552.             return;
  1553.          }
  1554.  
  1555.          this.currSelectedCell = get;
  1556.          lost.focusEvent(e);
  1557.          this.lostCapture();
  1558.       }
  1559.  
  1560.       try {
  1561.          if (oldRow != get.row()) {
  1562.             this.dataSource.setCurrentRow(get.row());
  1563.          }
  1564.       } catch (TypeNotSupported ex) {
  1565.          this.handleException(get.row(), get.col(), ex);
  1566.       }
  1567.  
  1568.       this.currSelectedCell = get;
  1569.       e.target = get;
  1570.       e.id = 1004;
  1571.       get.focusEvent(e);
  1572.       this.changeSelection(get.row(), get.col(), 0);
  1573.       this.clickTime = 0L;
  1574.    }
  1575.  
  1576.    public boolean mouseExit(Event e, int x, int y) {
  1577.       this.frame().setCursor(0);
  1578.       return true;
  1579.    }
  1580.  
  1581.    public boolean mouseDown(Event e, int x, int y) {
  1582.       if (e.target != this.vsb && e.target != this.hsb) {
  1583.          Rectangle r = new Rectangle();
  1584.          r = this.getTableBounds(r);
  1585.          if (!r.inside(x, y)) {
  1586.             return false;
  1587.          } else if (y < this.headingHeight + 1) {
  1588.             return this.handleHeadingClick(e, x, y);
  1589.          } else if (x < this.rowHeadingWidth && this.rowHeadingHints.visible) {
  1590.             return this.handleRowHeadingClick(e, x, y);
  1591.          } else if (x > this.width) {
  1592.             return true;
  1593.          } else {
  1594.             int row = this.cellRow(y);
  1595.             int col = this.columnClicked(x);
  1596.             TableCell newSelection = null;
  1597.             if (this.currSelectedCell != null && row == this.currSelectedCell.row() && col == this.currSelectedCell.col()) {
  1598.                this.handleSuccessiveClick(e);
  1599.             } else {
  1600.                if (!this.cells.contains(row, col)) {
  1601.                   if (!this.validRow(row)) {
  1602.                      return true;
  1603.                   }
  1604.  
  1605.                   newSelection = this.getDefaultCell(row, col).cloneCell();
  1606.                   newSelection.setDefaultFlag();
  1607.                } else {
  1608.                   newSelection = (TableCell)this.cells.elementAt(row, col);
  1609.                }
  1610.  
  1611.                this.sendFocusEvents(this.currSelectedCell, newSelection);
  1612.                if (this.cellHasCapture()) {
  1613.                   this.translate(e);
  1614.                   return this.currCaptureCell.mouseEvent(e);
  1615.                }
  1616.             }
  1617.  
  1618.             return false;
  1619.          }
  1620.       } else {
  1621.          return false;
  1622.       }
  1623.    }
  1624.  
  1625.    public boolean validRow(int row) {
  1626.       if (row < 0) {
  1627.          return false;
  1628.       } else if (this.cells.rows() - 1 > row) {
  1629.          return true;
  1630.       } else {
  1631.          try {
  1632.             this.dataSource.validDataRowRange(row, row);
  1633.             return true;
  1634.          } catch (DataNotAvailable var2) {
  1635.             return false;
  1636.          }
  1637.       }
  1638.    }
  1639.  
  1640.    public boolean validCol(int col) {
  1641.       return col >= 0 && col < this.getNumberOfCols();
  1642.    }
  1643.  
  1644.    public boolean mouseDrag(Event e, int x, int y) {
  1645.       if (this.isDragging) {
  1646.          this.handleColDrag(x);
  1647.          return true;
  1648.       } else if (this.cellHasCapture()) {
  1649.          this.translate(e);
  1650.          return this.currCaptureCell.mouseEvent(e);
  1651.       } else {
  1652.          return false;
  1653.       }
  1654.    }
  1655.  
  1656.    boolean captureByHeading() {
  1657.       if (this.currCaptureCell == null) {
  1658.          return false;
  1659.       } else {
  1660.          Coordinate c = this.currCaptureCell.getCoordinates();
  1661.          return this.colHeadings.contains(c.row, c.col, this.currCaptureCell) || this.cornerCell == this.currCaptureCell;
  1662.       }
  1663.    }
  1664.  
  1665.    boolean captureByRowHeading() {
  1666.       if (this.currCaptureCell == null) {
  1667.          return false;
  1668.       } else {
  1669.          return this.rowHeadingCell(this.currCaptureCell) || this.cornerCell == this.currCaptureCell;
  1670.       }
  1671.    }
  1672.  
  1673.    Event translate(Event e) {
  1674.       TableCell cell = this.currCaptureCell != null ? this.currCaptureCell : this.currSelectedCell;
  1675.       int row = cell.getCoordinates().row;
  1676.       int col = cell.getCoordinates().col;
  1677.       int currY = (row - this.topRow) * this.cellHeight + this.headingHeight + 2;
  1678.       int currX = this.splitters[col] - this.splitters[this.leftCol - 1];
  1679.       if (!this.captureByRowHeading()) {
  1680.          e.x -= currX + this.rowHeadingWidth;
  1681.       }
  1682.  
  1683.       if (!this.captureByHeading()) {
  1684.          e.y -= currY;
  1685.       }
  1686.  
  1687.       return e;
  1688.    }
  1689.  
  1690.    void handleColDrag(int x) {
  1691.       int shiftLeft = this.splitters[this.leftCol - 1] + this.rowHeadingWidth;
  1692.       if (this.dragColumn == 0) {
  1693.          this.rowHeadingWidth = x;
  1694.       } else if (x < this.splitters[this.dragColumn - 1] - shiftLeft) {
  1695.          x = this.splitters[this.dragColumn - 1] - shiftLeft;
  1696.       }
  1697.  
  1698.       this.field_1.setColor(((Component)this).getBackground());
  1699.       this.field_1.setXORMode(Color.black);
  1700.       this.field_1.drawLine(this.xDragLast, 0, this.xDragLast, ((Component)this).size().height);
  1701.       this.field_1.drawLine(x, 0, x, ((Component)this).size().height);
  1702.       this.field_1.setColor(Color.black);
  1703.       this.field_1.setPaintMode();
  1704.       this.xDragLast = x;
  1705.       ((Component)this).repaint();
  1706.    }
  1707.  
  1708.    public synchronized void resizeColumn(int col, int rightSide) {
  1709.       int diff = rightSide - this.splitters[col] + this.splitters[this.leftCol - 1];
  1710.       int len = this.splitters.length;
  1711.       this.splitters[col] = rightSide + this.splitters[this.leftCol - 1];
  1712.  
  1713.       for(int i = col + 1; i < len; ++i) {
  1714.          int[] var10000 = this.splitters;
  1715.          var10000[i] += diff;
  1716.       }
  1717.  
  1718.       this.redraw(true);
  1719.    }
  1720.  
  1721.    public boolean mouseUp(Event e, int x, int y) {
  1722.       if (this.isDragging) {
  1723.          this.field_1.setColor(((Component)this).getBackground());
  1724.          this.field_1.setXORMode(Color.black);
  1725.          this.field_1.drawLine(this.xDragLast, 0, this.xDragLast, ((Component)this).size().height);
  1726.          this.field_1.setColor(Color.black);
  1727.          this.field_1.setPaintMode();
  1728.          if (this.dragColumn == 0) {
  1729.             this.redraw(true);
  1730.          } else {
  1731.             this.resizeColumn(this.dragColumn, this.xDragLast - this.rowHeadingWidth);
  1732.          }
  1733.  
  1734.          this.xDragLast = -1;
  1735.          this.isDragging = false;
  1736.          return true;
  1737.       } else if (this.cellHasCapture()) {
  1738.          this.translate(e);
  1739.          return this.currCaptureCell.mouseEvent(e);
  1740.       } else {
  1741.          return false;
  1742.       }
  1743.    }
  1744.  
  1745.    public boolean mouseMove(Event ev, int x, int y) {
  1746.       boolean isCloseEnough = false;
  1747.       int shiftLeft = this.splitters[this.leftCol - 1] - this.rowHeadingWidth;
  1748.       if (y >= this.headingHeight || !(((Container)this).locate(x, y) instanceof Scrollbar) || !this.vsb.isVisible()) {
  1749.          if (this.rowHeadingHints.visible && x < this.rowHeadingWidth + this.clickMargin && y < this.headingHeight) {
  1750.             if (x < this.rowHeadingWidth + this.clickMargin && x > this.rowHeadingWidth - this.clickMargin) {
  1751.                isCloseEnough = true;
  1752.             }
  1753.          } else if (y < this.headingHeight) {
  1754.             for(int i = 1; i < this.splitters.length; ++i) {
  1755.                if (x < this.splitters[i] + this.clickMargin - shiftLeft && x > this.splitters[i] - this.clickMargin - shiftLeft) {
  1756.                   isCloseEnough = true;
  1757.                }
  1758.             }
  1759.          }
  1760.       }
  1761.  
  1762.       this.currentCursor = isCloseEnough ? 10 : 0;
  1763.       if (this.currentCursor != this.frame().getCursorType()) {
  1764.          this.frame().setCursor(this.currentCursor);
  1765.       }
  1766.  
  1767.       return false;
  1768.    }
  1769.  
  1770.    public boolean keyUp(Event e, int key) {
  1771.       if (this.currSelectedCell == null) {
  1772.          int row = this.topRow;
  1773.          int col = 0;
  1774.       } else {
  1775.          int row = this.currSelectedCell.row();
  1776.          int col = this.currSelectedCell.col();
  1777.       }
  1778.  
  1779.       if (this.currSelectedCell != null) {
  1780.          e.target = this.currSelectedCell;
  1781.          return this.currSelectedCell.keyEvent(e);
  1782.       } else {
  1783.          return false;
  1784.       }
  1785.    }
  1786.  
  1787.    public boolean lostFocus(Event e, Object o) {
  1788.       if (this.tabbed) {
  1789.          ((Component)this).requestFocus();
  1790.          this.tabbed = false;
  1791.       } else {
  1792.          if (this.currSelectedCell != null) {
  1793.             e.target = this.currSelectedCell;
  1794.             e.target = this;
  1795.             this.currSelectedCell.deactivateCursor();
  1796.          }
  1797.  
  1798.          this.lostCapture();
  1799.       }
  1800.  
  1801.       return false;
  1802.    }
  1803.  
  1804.    public boolean gotFocus(Event e, Object o) {
  1805.       if (this.currSelectedCell != null) {
  1806.          this.currSelectedCell.activateCursor();
  1807.       }
  1808.  
  1809.       return false;
  1810.    }
  1811.  
  1812.    TableCell getUniqueCell(int row, int col) {
  1813.       if (!this.cells.contains(row, col)) {
  1814.          TableCell cell = this.getDefaultCell(row, col).cloneCell();
  1815.          cell.setDefaultFlag();
  1816.          return cell;
  1817.       } else {
  1818.          return (TableCell)this.cells.elementAt(row, col);
  1819.       }
  1820.    }
  1821.  
  1822.    public boolean keyDown(Event e, int key) {
  1823.       boolean changed = false;
  1824.       if (this.eventHandler != null && this.isToolbarComponent(e.target)) {
  1825.          return this.eventHandler.handleToolbarEvent(e);
  1826.       } else {
  1827.          int row;
  1828.          int col;
  1829.          if (this.currSelectedCell == null) {
  1830.             row = this.topRow;
  1831.             col = 0;
  1832.          } else {
  1833.             row = this.currSelectedCell.row();
  1834.             col = this.currSelectedCell.col();
  1835.          }
  1836.  
  1837.          int dataRows = -1;
  1838.  
  1839.          try {
  1840.             dataRows = this.dataSource.validDataRowRange(0, row + 2);
  1841.          } catch (DataNotAvailable var8) {
  1842.          }
  1843.  
  1844.          switch (key) {
  1845.             case 9:
  1846.                this.tabbed = true;
  1847.                if (e.shiftDown()) {
  1848.                   if (col > 0) {
  1849.                      ((Component)this).requestFocus();
  1850.                      TableCell newSelection = this.getUniqueCell(row, col - 1);
  1851.                      this.sendFocusEvents(this.currSelectedCell, newSelection);
  1852.                   }
  1853.                } else if (col < this.getNumberOfCols() - 1) {
  1854.                   ((Component)this).requestFocus();
  1855.                   TableCell newSelection = this.getUniqueCell(row, col + 1);
  1856.                   this.sendFocusEvents(this.currSelectedCell, newSelection);
  1857.                }
  1858.                break;
  1859.             case 10:
  1860.             case 1005:
  1861.                if (this.currSelectedCell == null) {
  1862.                   return false;
  1863.                }
  1864.  
  1865.                if (!this.currSelectedCell.loseFocusOnArrow()) {
  1866.                   e.target = this.currSelectedCell;
  1867.                   return this.currSelectedCell.keyEvent(e);
  1868.                }
  1869.  
  1870.                if (row < this.cells.rows() - 1 || row < dataRows) {
  1871.                   TableCell newSelection = this.getUniqueCell(row + 1, col);
  1872.                   this.sendFocusEvents(this.currSelectedCell, newSelection);
  1873.                }
  1874.                break;
  1875.             case 1001:
  1876.                if (this.currSelectedCell == null || this.currSelectedCell.loseFocusOnArrow()) {
  1877.                   this.setCurrentCell(this.currSelectedCell.row() + 1, this.getNumberOfCols());
  1878.                   return true;
  1879.                }
  1880.             case 1000:
  1881.                if (this.currSelectedCell == null || this.currSelectedCell.loseFocusOnArrow()) {
  1882.                   this.setCurrentCell(this.currSelectedCell.row() + 1, 1);
  1883.                   return true;
  1884.                }
  1885.             default:
  1886.                if (this.currSelectedCell != null) {
  1887.                   e.target = this.currSelectedCell;
  1888.                   return this.currSelectedCell.keyEvent(e);
  1889.                }
  1890.                break;
  1891.             case 1002:
  1892.                this.scrollPageUp();
  1893.                changed = true;
  1894.                break;
  1895.             case 1003:
  1896.                this.scrollPageDown();
  1897.                changed = true;
  1898.                break;
  1899.             case 1004:
  1900.                if (this.currSelectedCell == null) {
  1901.                   return false;
  1902.                }
  1903.  
  1904.                if (!this.currSelectedCell.loseFocusOnArrow()) {
  1905.                   e.target = this.currSelectedCell;
  1906.                   return this.currSelectedCell.keyEvent(e);
  1907.                }
  1908.  
  1909.                if (row > 0) {
  1910.                   TableCell newSelection = this.getUniqueCell(row - 1, col);
  1911.                   this.sendFocusEvents(this.currSelectedCell, newSelection);
  1912.                }
  1913.                break;
  1914.             case 1006:
  1915.                if (this.currSelectedCell == null) {
  1916.                   return false;
  1917.                }
  1918.  
  1919.                if (!this.currSelectedCell.loseFocusOnArrow()) {
  1920.                   e.target = this.currSelectedCell;
  1921.                   return this.currSelectedCell.keyEvent(e);
  1922.                }
  1923.  
  1924.                if (col > 0) {
  1925.                   TableCell newSelection = this.getUniqueCell(row, col - 1);
  1926.                   this.sendFocusEvents(this.currSelectedCell, newSelection);
  1927.                }
  1928.                break;
  1929.             case 1007:
  1930.                if (this.currSelectedCell == null) {
  1931.                   return false;
  1932.                }
  1933.  
  1934.                if (!this.currSelectedCell.loseFocusOnArrow()) {
  1935.                   e.target = this.currSelectedCell;
  1936.                   return this.currSelectedCell.keyEvent(e);
  1937.                }
  1938.  
  1939.                if (col < this.getNumberOfCols() - 1) {
  1940.                   TableCell newSelection = this.getUniqueCell(row, col + 1);
  1941.                   this.sendFocusEvents(this.currSelectedCell, newSelection);
  1942.                }
  1943.          }
  1944.  
  1945.          if (changed) {
  1946.             this.redraw(true);
  1947.          }
  1948.  
  1949.          return false;
  1950.       }
  1951.    }
  1952.  
  1953.    public boolean handleEvent(Event e) {
  1954.       if (this.isToolbarComponent(e.target)) {
  1955.          if (e.target == this.gotoButton) {
  1956.             e.arg = this.gotoTextField.getText();
  1957.          }
  1958.  
  1959.          return this.eventHandler.handleToolbarEvent(e);
  1960.       } else {
  1961.          if (e.target instanceof Scrollbar && e.id == 605) {
  1962.             Date d = new Date();
  1963.             e.when = d.getTime();
  1964.             if (e.when - this.scrollbarTimer < 300L) {
  1965.                return false;
  1966.             }
  1967.  
  1968.             this.scrollbarTimer = e.when;
  1969.          }
  1970.  
  1971.          if (e.target == this.vsb && e.arg != null) {
  1972.             switch (e.id) {
  1973.                case 601:
  1974.                   this.scrollLineUp();
  1975.                   break;
  1976.                case 602:
  1977.                   this.scrollLineDown();
  1978.                   break;
  1979.                case 603:
  1980.                   this.scrollPageUp();
  1981.                   break;
  1982.                case 604:
  1983.                   this.scrollPageDown();
  1984.                   break;
  1985.                case 605:
  1986.                   this.scrollUpDownAbsolute(this.vsb.getValue());
  1987.             }
  1988.          }
  1989.  
  1990.          if (e.target == this.hsb && e.arg != null && this.leftCol != this.hsb.getValue()) {
  1991.             this.hsbPosition = this.leftCol = this.hsb.getValue();
  1992.             this.redraw();
  1993.             ((Component)this).getGraphics().drawImage(this.field_0, 0, 0, this);
  1994.          }
  1995.  
  1996.          if (e.target instanceof Scrollbar) {
  1997.             ((Component)this).requestFocus();
  1998.          }
  1999.  
  2000.          return super.handleEvent(e);
  2001.       }
  2002.    }
  2003.  
  2004.    public void gotoRow(int row) {
  2005.       if (row < this.topRow || row > this.topRow + this.getPageSize().height - 1) {
  2006.          this.scrollUpDownAbsolute(row);
  2007.       }
  2008.  
  2009.    }
  2010.  
  2011.    public synchronized void scrollUpTo(int newTop) {
  2012.       newTop = Math.max(0, newTop);
  2013.       if (newTop != this.topRow) {
  2014.          this.topRow = newTop;
  2015.          this.vsbPosition = this.topRow;
  2016.          this.vsb.setValue(this.vsbPosition);
  2017.          this.redraw(true);
  2018.       }
  2019.  
  2020.    }
  2021.  
  2022.    public void scrollUpDownAbsolute(int row) {
  2023.       if (row < this.topRow) {
  2024.          this.scrollUpTo(row);
  2025.       } else {
  2026.          this.scrollDownTo(row);
  2027.       }
  2028.    }
  2029.  
  2030.    public void scrollLineUp() {
  2031.       this.scrollUpTo(this.topRow - 1);
  2032.    }
  2033.  
  2034.    public void scrollPageUp() {
  2035.       this.scrollUpTo(this.topRow - this.getPageSize().height + 1);
  2036.    }
  2037.  
  2038.    public synchronized void scrollDownTo(int nextTop) {
  2039.       int lastRow = this.cells.rows() - 1;
  2040.  
  2041.       try {
  2042.          lastRow = Math.max(lastRow, this.dataSource.validDataRowRange(0, nextTop));
  2043.       } catch (DataNotAvailable var3) {
  2044.       }
  2045.  
  2046.       nextTop = Math.min(nextTop, lastRow);
  2047.       if (nextTop >= this.topRow) {
  2048.          this.vsbPosition = this.topRow = nextTop;
  2049.          this.vsb.setValue(this.vsbPosition);
  2050.          this.redraw(true);
  2051.       }
  2052.  
  2053.    }
  2054.  
  2055.    public void scrollLineDown() {
  2056.       this.scrollDownTo(this.topRow + 1);
  2057.    }
  2058.  
  2059.    public void scrollPageDown() {
  2060.       this.scrollDownTo(this.topRow + this.getPageSize().height - 1);
  2061.    }
  2062.  
  2063.    public synchronized void makeCellVisible(int row, int col) {
  2064.       boolean changed = false;
  2065.       int rc = this.cells.rows();
  2066.  
  2067.       try {
  2068.          rc = Math.max(rc, this.dataSource.validDataRowRange(0, row + 1) + 1);
  2069.       } catch (DataNotAvailable var5) {
  2070.       }
  2071.  
  2072.       row = Math.min(rc - 1, row);
  2073.       row = Math.max(0, row);
  2074.       col = Math.min(col, this.splitters.length);
  2075.       col = Math.max(0, col);
  2076.       if (row < this.topRow) {
  2077.          this.topRow = row;
  2078.          this.vsbPosition = this.topRow;
  2079.          this.vsb.setValue(this.vsbPosition);
  2080.          changed = true;
  2081.       }
  2082.  
  2083.       if (row > this.topRow + this.getPageSize().height - 1) {
  2084.          this.topRow = row - this.getPageSize().height + 1;
  2085.          this.vsbPosition = this.topRow;
  2086.          this.vsb.setValue(this.vsbPosition);
  2087.          changed = true;
  2088.       }
  2089.  
  2090.       ++col;
  2091.       if (col < this.leftCol) {
  2092.          this.leftCol = col < 1 ? 1 : col;
  2093.          this.hsbPosition = this.leftCol;
  2094.          this.hsb.setValue(this.hsbPosition);
  2095.          changed = true;
  2096.       }
  2097.  
  2098.       if (col > this.leftCol + this.getPageSize().width - 1) {
  2099.          this.hsbPosition = this.leftCol = col - this.getPageSize().width + 1;
  2100.          this.hsb.setValue(this.hsbPosition);
  2101.          changed = true;
  2102.       }
  2103.  
  2104.       if (changed) {
  2105.          this.redraw(true);
  2106.       }
  2107.  
  2108.    }
  2109.  
  2110.    void changeSelection(int row, int col, int modifiers) {
  2111.       switch (modifiers) {
  2112.          case 1:
  2113.          case 2:
  2114.          default:
  2115.             this.makeCellVisible(row, col);
  2116.       }
  2117.    }
  2118.  
  2119.    boolean postEvent(int id, int num) {
  2120.       Event e = new Event(this, id, new Integer(num));
  2121.       return ((Component)this).postEvent(e);
  2122.    }
  2123.  
  2124.    Dimension getPageSize() {
  2125.       Dimension d = ((Component)this).size();
  2126.  
  2127.       int i;
  2128.       for(i = this.leftCol; i < this.splitters.length && this.splitters[i] - this.splitters[this.leftCol - 1] <= d.width; ++i) {
  2129.       }
  2130.  
  2131.       d.width = i - this.leftCol;
  2132.       d.height -= this.bottomPanel.size().height;
  2133.       d.height = (d.height - this.headingHeight) / this.cellHeight;
  2134.       return d;
  2135.    }
  2136.  
  2137.    void drawHeadings(int numRowsToDraw) {
  2138.       MatrixEnumeration e = this.colHeadings.elements();
  2139.       TableCell c = null;
  2140.       int cols = this.getNumberOfCols();
  2141.  
  2142.       while(e.hasMoreElements() || c != null) {
  2143.          for(int col = this.leftCol - 1; col < cols; ++col) {
  2144.             this.getColumnWidth(col);
  2145.  
  2146.             while((c == null || e.currCol() < col) && e.hasMoreElements()) {
  2147.                c = (TableCell)e.nextElement();
  2148.                if (e.currCol() < col) {
  2149.                   c = null;
  2150.                }
  2151.             }
  2152.  
  2153.             if (e.currCol() == col) {
  2154.                this.hints.setHints(c);
  2155.                c.drawCell(this.field_1, this.hints);
  2156.                c = null;
  2157.             }
  2158.  
  2159.             if (c != null) {
  2160.                c = null;
  2161.             }
  2162.          }
  2163.       }
  2164.  
  2165.       this.drawRowHeadings(numRowsToDraw);
  2166.    }
  2167.  
  2168.    synchronized void redrawColHeadingCell(int col) {
  2169.       if (col >= this.leftCol - 1 && col < this.getNumberOfCols()) {
  2170.          TableCell cell = (TableCell)this.colHeadings.elementAt(0, col);
  2171.          this.hints.setHints(cell);
  2172.          cell.drawCell(this.field_1, this.hints);
  2173.       }
  2174.    }
  2175.  
  2176.    synchronized void redrawRowHeadingCell(int row) {
  2177.       if (this.rowHeadingHints.visible && this.validRow(row)) {
  2178.          if (this.rowHeadingCell(this.currCaptureCell) && this.currCaptureCell.row() == row) {
  2179.             this.hints.setHints(this.currHeadingCell);
  2180.             this.currHeadingCell.drawCell(this.field_1, this.hints);
  2181.          } else {
  2182.             TableCell cell = this.headingCell.cloneCell();
  2183.             cell.setRow(row);
  2184.             this.hints.setHints(cell);
  2185.             cell.drawCell(this.field_1, this.hints);
  2186.          }
  2187.       }
  2188.    }
  2189.  
  2190.    void drawRowHeadings(int count) {
  2191.       if (this.rowHeadingHints.visible) {
  2192.          TableCell cell = this.headingCell.cloneCell();
  2193.          cell.getCoordinates();
  2194.  
  2195.          for(int i = 0; i < count; ++i) {
  2196.             cell.setRow(i + this.topRow);
  2197.             this.hints.setHints(cell);
  2198.             cell.drawCell(this.field_1, this.hints);
  2199.          }
  2200.  
  2201.          if (this.rowHeadingCell(this.currCaptureCell)) {
  2202.             this.hints.setHints(this.currHeadingCell);
  2203.             this.currHeadingCell.drawCell(this.field_1, this.hints);
  2204.          }
  2205.  
  2206.          this.redrawCornerCell();
  2207.       }
  2208.    }
  2209.  
  2210.    synchronized void redrawCornerCell() {
  2211.       this.hints.setHints(this.cornerCell);
  2212.       this.cornerCell.drawCell(this.field_1, this.hints);
  2213.    }
  2214.  
  2215.    Frame frame() {
  2216.       Container c;
  2217.       for(c = this; !(c instanceof Frame); c = ((Component)c).getParent()) {
  2218.       }
  2219.  
  2220.       return (Frame)c;
  2221.    }
  2222.  
  2223.    public CellHints getCellHints(int row, int col) {
  2224.       ++row;
  2225.       ++col;
  2226.       return this.cellAttributes.contains(row, col) ? (CellHints)this.cellAttributes.elementAt(row, col) : null;
  2227.    }
  2228.  
  2229.    public CellHints getRowHints(int row) {
  2230.       ++row;
  2231.       return this.cellAttributes.contains(row, 0) ? (CellHints)this.cellAttributes.elementAt(row, 0) : null;
  2232.    }
  2233.  
  2234.    public CellHints getColHints(int col) {
  2235.       ++col;
  2236.       return (CellHints)this.cellAttributes.elementAt(0, col);
  2237.    }
  2238.  
  2239.    public CellHints getHeadingHints(int row, int col) {
  2240.       return (CellHints)this.headingAttributes.elementAt(row, col);
  2241.    }
  2242.  
  2243.    public CellHints getHintsForCell(TableCell c, int row, int col) {
  2244.       if (this.rowHeadingCell(c)) {
  2245.          return this.rowHeadingHints;
  2246.       } else if (c.type() == 1) {
  2247.          return this.getHeadingHints(row, col + 1);
  2248.       } else {
  2249.          CellHints h = this.getCellHints(row, col);
  2250.          if (h != null) {
  2251.             return h;
  2252.          } else {
  2253.             h = this.getRowHints(row);
  2254.             if (h != null) {
  2255.                return h;
  2256.             } else {
  2257.                h = this.getColHints(col);
  2258.                return h;
  2259.             }
  2260.          }
  2261.       }
  2262.    }
  2263.  
  2264.    public int getCellAlignment(TableCell c) {
  2265.       CellHints h = this.getHintsForCell(c, c.row(), c.col());
  2266.       return h.alignment();
  2267.    }
  2268.  
  2269.    public Color getCellFG(TableCell c) {
  2270.       CellHints h = this.getHintsForCell(c, c.row(), c.col());
  2271.       return h.foreground();
  2272.    }
  2273.  
  2274.    public Color getCellBG(TableCell c) {
  2275.       CellHints h = this.getHintsForCell(c, c.row(), c.col());
  2276.       return h.background();
  2277.    }
  2278.  
  2279.    boolean getCellEditable(TableCell c) {
  2280.       CellHints h = this.getHintsForCell(c, c.row(), c.col());
  2281.       return h.editable();
  2282.    }
  2283.  
  2284.    boolean getCellHighlighted(TableCell c) {
  2285.       int row = c.row() + 1;
  2286.       int col = c.col() + 1;
  2287.       if (c.type() == 1) {
  2288.          this.isColumnSelected(col);
  2289.       } else {
  2290.          if (c == this.cornerCell) {
  2291.             return this.isViewSelected();
  2292.          }
  2293.  
  2294.          if (this.rowHeadingCell(c)) {
  2295.             if (!this.isRowSelected(row) && !this.isCellSelected(row, col)) {
  2296.                return false;
  2297.             }
  2298.  
  2299.             return true;
  2300.          }
  2301.       }
  2302.  
  2303.       return this.isCellSelected(row, col);
  2304.    }
  2305.  
  2306.    Font getCellFont(TableCell c) {
  2307.       CellHints h = this.getHintsForCell(c, c.row(), c.col());
  2308.       return h.font();
  2309.    }
  2310.  
  2311.    boolean getCellVisibility(TableCell c) {
  2312.       if (this.rowHeadingCell(c)) {
  2313.          return this.rowHeadingHints.visible;
  2314.       } else if (c.type() == 1) {
  2315.          return this.getHeadingHints(c.row(), c.col() + 1).isVisible();
  2316.       } else {
  2317.          CellHints h = this.getCellHints(c.row(), c.col());
  2318.          if (h != null && !h.isVisible()) {
  2319.             return false;
  2320.          } else {
  2321.             h = this.getRowHints(c.row());
  2322.             if (h != null && !h.isVisible()) {
  2323.                return false;
  2324.             } else {
  2325.                h = this.getColHints(c.col());
  2326.                return h.isVisible();
  2327.             }
  2328.          }
  2329.       }
  2330.    }
  2331.  
  2332.    public boolean isRowSelected(int row) {
  2333.       return this.selected.get(this.tx4Sxn(row));
  2334.    }
  2335.  
  2336.    public boolean isCellSelected(int row, int col) {
  2337.       return this.selected.get(this.tx4Sxn(row, col));
  2338.    }
  2339.  
  2340.    public boolean isColumnSelected(int col) {
  2341.       return this.selected.get(col);
  2342.    }
  2343.  
  2344.    public boolean isViewSelected() {
  2345.       return this.selected.get(0);
  2346.    }
  2347.  
  2348.    public void toggleCell(int row, int col) {
  2349.       if (!this.isRowSelected(row)) {
  2350.          this.toggleBit(this.tx4Sxn(row, col));
  2351.       }
  2352.  
  2353.    }
  2354.  
  2355.    public Coordinate[] getSelectedCells() {
  2356.       Vector cells = new Vector();
  2357.       int cols = this.getNumberOfCols();
  2358.       int rows = this.sxnRows(cols);
  2359.  
  2360.       for(int row = 1; row < rows; ++row) {
  2361.          for(int col = 1; col < cols; ++col) {
  2362.             if (this.selected.get(this.tx4Sxn(row, col))) {
  2363.                cells.addElement(new Coordinate(row, col));
  2364.             }
  2365.          }
  2366.       }
  2367.  
  2368.       Coordinate[] sxn = new Coordinate[cells.size()];
  2369.       cells.copyInto(sxn);
  2370.       return sxn;
  2371.    }
  2372.  
  2373.    public int getFirstSelectedRow() {
  2374.       int cols = this.getNumberOfCols();
  2375.       int total = this.selected.size();
  2376.       int row = 1;
  2377.  
  2378.       for(int index = cols + 1; index < total; ++row) {
  2379.          if (this.selected.get(index)) {
  2380.             return row;
  2381.          }
  2382.  
  2383.          index += cols + 1;
  2384.       }
  2385.  
  2386.       return -1;
  2387.    }
  2388.  
  2389.    public int[] getSelectedRows() {
  2390.       int cols = this.getNumberOfCols();
  2391.       int total = this.selected.size();
  2392.       int[] srows = new int[this.dataSource.rows()];
  2393.       int row = 1;
  2394.       int next = 0;
  2395.  
  2396.       for(int index = cols + 1; index < total; ++row) {
  2397.          if (this.selected.get(index)) {
  2398.             srows[next++] = row;
  2399.          }
  2400.  
  2401.          index += cols + 1;
  2402.       }
  2403.  
  2404.       int[] sxn = new int[next];
  2405.       System.arraycopy(srows, 0, sxn, 0, next);
  2406.       return sxn;
  2407.    }
  2408.  
  2409.    public int[] getSelectedCols() {
  2410.       int cols = this.getNumberOfCols();
  2411.       int[] scols = new int[cols];
  2412.       int next = 0;
  2413.  
  2414.       for(int col = 1; col <= cols; ++col) {
  2415.          if (this.selected.get(col)) {
  2416.             scols[next - 1] = col;
  2417.             ++next;
  2418.          }
  2419.       }
  2420.  
  2421.       int[] sxn = new int[next];
  2422.       System.arraycopy(scols, 0, sxn, 0, next);
  2423.       return sxn;
  2424.    }
  2425.  
  2426.    public boolean isRowSet(int row) {
  2427.       return this.selected.get(this.tx4Sxn(row));
  2428.    }
  2429.  
  2430.    public synchronized void setRow(int row, boolean setTo) {
  2431.       int bit = this.tx4Sxn(row);
  2432.       int cols = this.getNumberOfCols();
  2433.  
  2434.       for(int i = 0; i <= cols; ++i) {
  2435.          if (setTo) {
  2436.             this.selected.set(bit + i);
  2437.          } else {
  2438.             this.selected.clear(bit + i);
  2439.          }
  2440.       }
  2441.  
  2442.       this.selectionMade = true;
  2443.       if (this.autoRedraw) {
  2444.          this.redrawRow(row);
  2445.       }
  2446.  
  2447.    }
  2448.  
  2449.    public synchronized void toggleRow(int row) {
  2450.       int bit = this.tx4Sxn(row);
  2451.       boolean set = this.selected.get(bit);
  2452.       int cols = this.getNumberOfCols();
  2453.  
  2454.       for(int i = 0; i <= cols; ++i) {
  2455.          if (set) {
  2456.             this.selected.clear(bit + i);
  2457.          } else {
  2458.             this.selected.set(bit + i);
  2459.          }
  2460.       }
  2461.  
  2462.       this.selectionMade = true;
  2463.       if (this.autoRedraw) {
  2464.          this.redrawRow(row);
  2465.       }
  2466.  
  2467.    }
  2468.  
  2469.    public synchronized void toggleCol(int col) {
  2470.       boolean set = this.selected.get(col);
  2471.       int cols = this.getNumberOfCols();
  2472.       int total = this.selected.size();
  2473.  
  2474.       for(int i = col; i <= total; i += cols + 1) {
  2475.          if (set) {
  2476.             this.selected.clear(i);
  2477.          } else {
  2478.             this.selected.set(i);
  2479.          }
  2480.       }
  2481.  
  2482.       this.selectionMade = true;
  2483.       if (this.autoRedraw) {
  2484.          this.redraw(true);
  2485.       }
  2486.  
  2487.    }
  2488.  
  2489.    public synchronized void toggleAll() {
  2490.       if (this.selected.get(0)) {
  2491.          this.clearAllSelections();
  2492.       } else {
  2493.          int total = this.selected.size();
  2494.  
  2495.          for(int i = 0; i < total; ++i) {
  2496.             this.selected.set(i);
  2497.          }
  2498.  
  2499.          this.selectionMade = true;
  2500.       }
  2501.  
  2502.       if (this.autoRedraw) {
  2503.          this.redraw(true);
  2504.       }
  2505.  
  2506.    }
  2507.  
  2508.    public synchronized void clearAllSelections() {
  2509.       if (this.selectionMade) {
  2510.          this.selectionBase = null;
  2511.          this.selectionLimit = null;
  2512.          this.selectionMade = false;
  2513.          this.selected.xor(this.selected);
  2514.          if (this.autoRedraw) {
  2515.             this.redraw(true);
  2516.          }
  2517.       }
  2518.  
  2519.    }
  2520.  
  2521.    public void setSelectionBase(int row, int col) {
  2522.       this.selectionBase = new Coordinate(row, col);
  2523.    }
  2524.  
  2525.    public boolean isSelectionBaseSet() {
  2526.       return this.selectionBase != null;
  2527.    }
  2528.  
  2529.    public boolean isRangeSelected() {
  2530.       return this.selectionLimit != null;
  2531.    }
  2532.  
  2533.    public void eraseRangeSelection() {
  2534.       this.setRange(false);
  2535.    }
  2536.  
  2537.    synchronized void setRange(boolean setTo) {
  2538.       if (this.selectionBase != null) {
  2539.          if (this.selectionLimit == null) {
  2540.             this.selectionLimit = this.selectionBase;
  2541.          }
  2542.  
  2543.          int topRow = Math.min(this.selectionBase.row, this.selectionLimit.row);
  2544.          Math.min(this.selectionBase.col, this.selectionLimit.col);
  2545.          int bottomRow = Math.max(this.selectionBase.row, this.selectionLimit.row);
  2546.          Math.max(this.selectionBase.col, this.selectionLimit.col);
  2547.          boolean auto = this.autoRedraw;
  2548.          this.autoRedraw = false;
  2549.          if (this.selectionBase.col == 0 && this.selectionLimit.col == 0) {
  2550.             for(int row = topRow; row <= bottomRow; ++row) {
  2551.                this.setRow(row, setTo);
  2552.             }
  2553.          }
  2554.  
  2555.          this.autoRedraw = auto;
  2556.          if (this.autoRedraw) {
  2557.             this.redraw(true);
  2558.          }
  2559.  
  2560.       }
  2561.    }
  2562.  
  2563.    public void clearRangeSelection() {
  2564.       this.eraseRangeSelection();
  2565.       this.selectionBase = null;
  2566.       this.selectionLimit = null;
  2567.    }
  2568.  
  2569.    public synchronized void selectRange(int limitRow, int limitCol) {
  2570.       if (this.selectionBase == null) {
  2571.          this.selectionBase = new Coordinate(limitRow, limitCol);
  2572.       }
  2573.  
  2574.       boolean auto = this.autoRedraw;
  2575.       this.autoRedraw = false;
  2576.       this.eraseRangeSelection();
  2577.       this.selectionLimit = new Coordinate(limitRow, limitCol);
  2578.       this.setRange(true);
  2579.       this.autoRedraw = auto;
  2580.       if (this.autoRedraw) {
  2581.          this.redraw(true);
  2582.       }
  2583.  
  2584.    }
  2585.  
  2586.    public void selectRange(int baseRow, int baseCol, int limitRow, int limitCol) {
  2587.       this.clearRangeSelection();
  2588.       this.selectionBase = new Coordinate(baseRow, baseCol);
  2589.       this.selectRange(limitRow, limitCol);
  2590.    }
  2591.  
  2592.    final void toggleBit(int bit) {
  2593.       this.selectionMade = true;
  2594.       if (this.selected.get(bit)) {
  2595.          this.selected.clear(bit);
  2596.       } else {
  2597.          this.selected.set(bit);
  2598.       }
  2599.    }
  2600.  
  2601.    final int tx4Sxn(int row, int col) {
  2602.       return this.tx4Sxn(row) + col;
  2603.    }
  2604.  
  2605.    final int tx4Sxn(int row) {
  2606.       int cols = this.getNumberOfCols();
  2607.       return (cols + 1) * row;
  2608.    }
  2609.  
  2610.    final int sxnRows(int cols) {
  2611.       return (int)Math.ceil((double)((float)this.selected.size() / ((float)cols + 1.0F)));
  2612.    }
  2613. }
  2614.